package cn.jy.erp.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jy.erp.domain.mobile.Partsmade;
import cn.jy.erp.domain.mobile.PartsmadeDetail;
import cn.jy.erp.mapper.mobile.ZzmenuMapper;
import cn.jy.erp.service.MobileZzmenuService;
@Service
public class MoblieZzmenuServiceImpl implements MobileZzmenuService{
	@Autowired
	ZzmenuMapper mapper;
	@Override
	public List<Partsmade> selectMenu() {
		return mapper.selectMenu();
	}
	@Override
	public List<PartsmadeDetail> selectByTid(String id) {
		return mapper.selectByTid(id);
	}
	@Override
	public List<PartsmadeDetail> selectByTidDid(String id, String did) {
		return mapper.selectByTidDid(id, did);
	}
	@Override
	public String saveorupdate(PartsmadeDetail t) {
		if(!t.getDid().equals("")&&!t.getDid().equals("null")){
			 SimpleDateFormat st =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			 Date date = new Date();
			 String string = st.format(date);
			if(t.getNeeder()==null||t.getNeeder().equals("")){
				 t.setNeeder(string);
			 }else {
				 t.setOveraddtime(string);
			 }
			mapper.updateZzdetail(t);
			return "0";
		}else{
			 String uuid = UUID.randomUUID().toString().replaceAll("-", "");
			 t.setDid(uuid);
			 SimpleDateFormat st =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			 Date date = new Date();
			 String string = st.format(date);
			 if(t.getNeeder()==null||t.getNeeder().equals("")){
				 t.setNeeder(string);
			 }else{
				 t.setOveraddtime(string);
			 }
			 mapper.saveZzDetail(t);
			 return "1";
		}
		// TODO Auto-generated method stub 
		
	}

}
